package com.briup.ch05;
/*私有的卡号id,余额balance*/
public class Account {
    private String id;
    private double balance;
    public void setId(String id)
    {
        this.id=id;
    }
    public void setBalance(double balance)
    {
        this.balance=balance;
    }
    public String getId()
    {
        return this.id;
    }
    private double getBalance()
    {
        return this.balance;
    }
    public double show(String id)
    {
        if(this.id.equals(id))//id==this.id
        {
            //return this.balance
            return this.getBalance();
        }
        else
        {
            System.out.println("卡号错误");
            return -1;
        }
    }
    //构造器/构造方法：在创建对象的同时完成的工作
    //和类名同名的方法且无返回值
    public Account(String id)
    {
        this.id=id;
        System.out.println("构造方法");
    }
    public Account(double balance)
    {
        this.balance=balance;
    }
    public Account()
    {
        //系统默认无参构造西
    }
}
